#include <bits/stdc++.h>
#include "../../tools/tools.h"
using namespace std;

constexpr int INF = 0x7fffffff; // 无穷大
typedef long long ll;

class Solution {
public:
    int numberOfChild(int n, int k) {
        k %= (2 * n - 2);
        if(k < n) return k;
        else return 2 * n - 2 - k;
    }
};

int main(int argc, const char** argv) {
    Solution s;
    debug(s.numberOfChild(3, 5));
    debug(s.numberOfChild(5, 6));
    debug(s.numberOfChild(4, 2));
    return 0;
}
